package com.config;

import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Resource
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**") //拦截所有请求
                .excludePathPatterns("/test/**") //放行所有测试请求
                .excludePathPatterns("/error/**") //放行所有异常重定向|转发的请求
                .excludePathPatterns("/wx/login", "/checkLogin", "/test/upload"); //放行白名单
    }

}
